package cn.itlaobing.eshopmanagement.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.itlaobing.eshopmanagement.entity.SystemAccount;
import cn.itlaobing.eshopmanagement.mapper.SystemAccountMapper;
import cn.itlaobing.eshopmanagement.service.SystemAccountService;

@Service
public class SystemAccountServiceImpl implements SystemAccountService{

	@Autowired
	private SystemAccountMapper systemAccountMapper;
	
	@Override
	public List<SystemAccount> findAll(Map<String, String> searchFilter) {
		if (searchFilter == null) {
			searchFilter = new HashMap<>();
		}
		if (StringUtils.isBlank(searchFilter.get("pageNum"))) {
			searchFilter.put("pageNum", "1");
		}
		if (StringUtils.isBlank(searchFilter.get("pageSize"))) {
			searchFilter.put("pageSize", "5");
		}
		return systemAccountMapper.selectByPrimary(searchFilter);
	}

	@Override
	public SystemAccount selectByPrimaryAccount(String account) {
		SystemAccount systemAccount=systemAccountMapper.selectByPrimaryAccount(account);
		if(StringUtils.isNoneBlank(ArrayUtils.toString(systemAccount))){
			return systemAccount;
		}	
		return null;
	}

	@Override
	public SystemAccount selectByPrimaryKey(Long id) {
		return systemAccountMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(SystemAccount record) {
		return systemAccountMapper.updateByPrimaryKeySelective(record);
	}
	
}
